#include<iostream>
using namespace std;
const int N=1e5+10;
int a[N];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0;
	int idx=1;
	a[n+1]=0;
	while(idx<=n){
		if(a[idx]<a[idx+1]){
			bool flag=0;
			while(a[idx]<=a[idx+1]){
				if(!flag){
					ans++;
					flag=1;
				}
				idx++;
			}
		}
		else if(a[idx]==a[idx+1]) idx++;
		else{
			bool flag=0;
			while(a[idx]>=a[idx+1]){
				if(!flag){
					ans++;
					flag=1;
				}
				idx++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	int flag=0;
	if(a[1]==a[2])flag=3;
	else flag=a[1]<a[2]?1:2;
	//1 递增 2递减
	for(int i=3;i<=n;i++){
		if(a[i] == a[i-1])continue;
		else if(a[i-1]<a[i] && flag == 2){
			ans++;
			if(i+1<=n){
				if(a[i]==a[i+1]){
					flag=3;
					continue;
				}
				flag=a[i]<a[i+1]?1:2;
			}
		}
		else if(a[i-1]>a[i] && flag == 1){
			ans++;	
			if(i+1<=n){
				if(a[i]==a[i+1]){
					flag=3;
					continue;
				}
				flag=a[i]<a[i+1]?1:2;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
*/
